    //
//  UploadViewController.m
//  pkphotomap
//
//  Created by Ed Mancebo on 3/31/11.
//  Copyright 2011 Personal. All rights reserved.
//

#import "UploadViewController.h"


@implementation UploadViewController

// The designated initializer.  Override if you create the controller programmatically and want to perform customization that is not appropriate for viewDidLoad.
/*
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization.
    }
    return self;
}
*/


// Implement loadView to create a view hierarchy programmatically, without using a nib.
- (void)loadView {
	
	CGRect bounds = [[UIScreen mainScreen] bounds];
	
	// TODO: do not hard code this
	int tabBarHeight = 49;
	int statusBarHeight = 20;
	NSLog(@"Bounds = (%d, %d)", bounds.origin.x, bounds.origin.y);
	
	CGRect frame;
	frame.origin.x = 0;
	frame.origin.y = 0;
	frame.size.width = bounds.size.width;
	frame.size.height = bounds.size.height - tabBarHeight - statusBarHeight;
	
	uiView = [[UIView alloc] initWithFrame:frame];
	
	UIButton *button = [UIButton buttonWithType:UIButtonTypeRoundedRect];
	button.frame = CGRectMake(50, 50, 100, 50);
	[button setTitle:@"Use camera" forState:UIControlStateNormal];
	[uiView addSubview:button];
	
	button = [UIButton buttonWithType:UIButtonTypeRoundedRect];
	button.frame = CGRectMake(50, 250, 200, 50);
	[button setTitle:@"Use photo library" forState:UIControlStateNormal];
	
	[button addTarget:self action:@selector(showPhotoLibrary:) forControlEvents:UIControlEventTouchUpInside];
	
	[uiView addSubview:button];

	[self setView:uiView];
}

- (void) showPhotoLibrary:(id)sender {
	UIImagePickerController *imagePicker = [[UIImagePickerController alloc] init];
	imagePicker.delegate = self;
	//imagePicker.sourceType = UIImagePickerControllerSourceTypeCamera;
	[self presentModalViewController:imagePicker animated:YES];
	[imagePicker release];
}

- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {
	NSLog(@"Picked image");
	[self dismissModalViewControllerAnimated:YES];
}

/*
// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad {
    [super viewDidLoad];
}
*/

/*
// Override to allow orientations other than the default portrait orientation.
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    // Return YES for supported orientations.
    return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
*/

- (void)didReceiveMemoryWarning {
    // Releases the view if it doesn't have a superview.
    [super didReceiveMemoryWarning];
    
    // Release any cached data, images, etc. that aren't in use.
}

- (void)viewDidUnload {
    [super viewDidUnload];
    // Release any retained subviews of the main view.
    // e.g. self.myOutlet = nil;
}


- (void)dealloc {
    [super dealloc];
}


@end
